<?php
namespace app\admin\controller;
use think\Controller;
use app\admin\controller\Common;
use app\service\orderService;
use app\service\apiService;
use app\service\camService;
use app\service\packageService;
use printing\printing;
use think\Db;
use think\Log;
use think\request;
use think\db\Where;

use \PhpOffice\PhpSpreadsheet\IOFactory;
use \PhpOffice\PhpSpreadsheet\Spreadsheet;
class Order extends Common{
	
	public function orderList(){
		$adminId = session('id');
        $usertype = Db::name('admin')->where('id',$adminId)->value('usertype');
        $this->assign('usertype',$usertype);
        //根据当前账号查询区域
        $com = (new Common())->pidTokenId();
        $whe=new Where();
        //$com['community_id']=implode(',',$com['community_id']);
        $whe['community_id'] = array('in',$com['community_id']);
        
        //根据账号查询停车场
        $parkinglist = (new orderService())->parkingList($whe);
        
        $this->assign('parkinglist',$parkinglist);
        $parkingNo = $this->getParkingNo();
        //搜索
        $data = request()->get();
		//var_dump($data);
		//$where=new Where();
		$where=array();
		$clientList=array();
        if (!empty($data)){
            if(!empty($data['parkingNo'])){
                //$where['parkingNo'] = $data['parkingNo'];//停车场名称
                $where[]=['a.parkingNo','=',$data['parkingNo']];
                $clientList=Db::table("parking_client")->where("parkingNo",$data['parkingNo'])->select();
            }
            if(!empty($data['clientNo'])){

                $where[]=['a.clientNo','=',$data['clientNo']];
            }
            if(!empty($data['payType'])){
                //$where['payType'] = $data['payType'];
                $where[]=['a.payType','=',$data['payType']];
            }
            if(!empty($data['carPlateNo'])){
                //echo 2;carPlateNo
                //$where['carPlateNo'] = $data['carPlateNo'];
                $where[]=['a.carPlateNo','like','%'.$data['carPlateNo'].'%'];
            }
            
            if((!empty($data['start_time']))&&(empty($data['end_time']))){
				$where[]=['a.paytime','>=',date("YmdHis",strtotime($data['start_time']))];
                
            }
			if((!empty($data['end_time']))&&(empty($data['start_time']))){
				$where[]=['a.paytime','<=',date("YmdHis",strtotime($data['end_time']))];
                
            }
			if((!empty($data['start_time']))&&(!empty($data['end_time']))){
				
                $where[]=[ 'a.paytime',[">=",date("YmdHis",strtotime($data['start_time']))],["<=",date("YmdHis",strtotime($data['end_time']))],'and'];
            }
        }
        $this->assign("clientList",$clientList);
        //var_dump($where);
		//$where=array_filter($where);
		$export = $where;
        $export = json_encode($export);
        $export = str_replace("\"","|",$export);
        $this->assign('export',$export);
        $page = request()->has('page') ? request()->get('page') : 1;
        //多条件查询地库车位信息
        /*$orderlist =Db::name('car_order')
                    ->alias("a")
                    ->join("parking_client b","a.parkingNo=b.parkingNo")
                    ->where("a.clientNo=b.clientNo")
                    ->where('a.parkingNo','in',$parkingNo)
                    ->where($where)
                    ->field("a.*,b.clientName")
                    ->order("a.order_id desc")
                    ->paginate(100, false, [
                        'page'  =>  $page,
                        'query' =>  $where
                    ]);*/
        $query=array_filter($data);
        $orderlist =Db::name('car_order')
            ->alias("a")
            ->join("parking_client b","a.parkingNo=b.parkingNo")
            ->where("a.clientNo=b.clientNo")
            ->where('a.parkingNo','in',$parkingNo)
            ->where($where)
            ->field("a.*,b.clientName")
            ->order("a.order_id desc")
            ->paginate(100, false, [
                'page'  =>  $page,
                'query' =>  $query
            ]);
        $money["ali"]=Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->where("a.payType","1")->sum("amountDue");
        $money["wx"]=Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->where("a.payType","2")->sum("amountDue");
        //$money["cash"]=Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->where("a.payType","cash")->sum("amountDue");
        $money["cash"]=0;
        $money["coupon"]=Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->where("a.payType","3")->sum("amountDue");
        $this->assign("money",$money);
        $number = Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->count();
        $this->assign('number',$number);
        $this->assign('list',$orderlist);
        $this->assign('orderlist',$orderlist);
        foreach ($data as $k => $v) {
			$this->assign($k, $v);
			
        }
        return $this->fetch('order_list');
    }
    public function getClient(){
        $parkingNo=request()->post("parkingNo");
        $data=Db::table("parking_client")->where("parkingNo",$parkingNo)->select();
        $str="<option value=''>客户端</option>";
        foreach($data as $value){
            $str=$str."<option value=".$value["clientNo"].">".$value["clientName"]."</option>";
        }
        echo $str;
    }
	
	public function invoiceList(){
	    $adminId = session('id');
        $usertype = Db::name('admin')->where('id',$adminId)->value('usertype');
        $this->assign('usertype',$usertype);
        //根据当前账号查询区域
        $com = (new Common())->pidTokenId();
        $whe=new Where();
        //$com['community_id']=implode(',',$com['community_id']);
        $whe['community_id'] = array('in',$com['community_id']);
        
        //根据账号查询停车场
        $parkinglist = (new orderService())->parkingList($whe);
        
        $this->assign('parkinglist',$parkinglist);
        $parkingNo = $this->getParkingNo();
        //搜索
        $data = request()->get();
		
		$where=array();
        if (!empty($data)){
            if(!empty($data['parkingNo'])){
                //$where['parkingNo'] = $data['parkingNo'];//停车场名称
                $where[]=['a.parkingNo','=',$data['parkingNo']];
            }
            if(!empty($data['payType'])){
                //$where['payType'] = $data['payType'];
                $where[]=['a.payType','=',$data['payType']];
            }
            if(!empty($data['carPlateNo'])){
                //$where['carPlateNo'] = $data['carPlateNo'];
                $where[]=['a.carPlateNo','=',$data['carPlateNo']];
            }
            
        }
		$export = $where;
        $export = json_encode($export);
        $export = str_replace("\"","|",$export);
        $this->assign('export',$export);
        $page = request()->has('page') ? request()->get('page') : 1;
        
        $invoicelist =Db::name('car_order')
                        ->alias("a")
                        //->leftJoin("car_order_invoice b","a.order_id=b.order_id")
                        ->join("car_order_invoice b","a.order_id=b.order_id")
                        ->where('a.parkingNo','in',$parkingNo)
                        ->where($where)
                        ->field("a.order_id,a.parkingName,a.parkingNo,a.carPlateNo,a.amountDue,b.*")
                        ->order("a.order_id desc")
                        ->paginate(100, false, [
                                'page'  =>  $page,
                                'query' =>  $where
                            ]);
        
        $number = Db::name('car_order')
                    ->alias("a")
                    ->where('a.parkingNo','in',$parkingNo)->where($where)->count();
        $this->assign('number',$number);
        $this->assign('list',$invoicelist);
        $this->assign('invoicelist',$invoicelist);
        foreach ($data as $k => $v) {
			$this->assign($k, $v);
			
        }
        return $this->fetch('invoice_list');
	}
	
	
	//查询发票
    public function checkEInvoice(){
        $order_id=request()->get("order_id");
        //查询发票序列号
        $data=Db::table('car_order_invoice')
                        ->alias("a")
                        ->join("car_order b","a.order_id=b.order_id")
                        ->where("a.order_id",$order_id)
                        ->field("a.*,b.parkingNo,b.out_trade_no")
                        ->find();
        if(!empty($data["invoiceFileUrl"])){
            return $this->redirect($data["invoiceFileUrl"]);
            $data["errorCode"]="0";
            return $data;
            
        }
       	//根据商家id查询开票信息
	    $serviceinfo=(new invoiceService())->parkingInvoice($data["parkingNo"]);
        
       //判断access_token是否到期
        $second = strtotime(date('Y-m-d H:i:s',time()))-strtotime($serviceinfo['fp_expires_in']);
        if($second <86400){
            //未过期
            $access_token = $serviceinfo['fp_access_token'];
        }else{
            //过期从新获取
            $res = (new invoiceService())->getToken($serviceinfo['service_id']);
            if(array_key_exists("error",$res)){
                return $res;
                return $res["error_description"];
            }
            $access_token = $res['fp_access_token'];
        }
         //var_dump($access_token);die;
        $timestmp = time();
       
		$webinfo=Db::table("webset")->where("id","1")->find();
		$appKey = $webinfo["appKey"];
     	$appSecret = $webinfo["appSecret"];
    	$token = $access_token;// please store the token and refresh it before expired
    	$taxnum = $serviceinfo["fp_saler_tax_num"];
    
    	$url = "https://sdk.nuonuo.com/open/v1/services"; // change to online domain
    	$method = "nuonuo.electronInvoice.CheckEInvoice"; // change to your method
		$senid = uniqid(); // generate your meaningful senid
		$body = json_encode(
			array(
				"invoiceSerialNum" => array($data['invoice_serial_num'])
			)
		);
        
		$result = Api::sendPostSyncRequest($url, $senid, $appKey, $appSecret, $token, $taxnum, $method, $body);

        
        $result = json_decode($result, true);
        
        if($result['code'] == 'E0000'){
            //return $result['result'][0]['invoiceFileUrl'];
            Db::table("car_order_invoice")
                ->where('order_id',$order_id)
                ->update([
                    "invoiceFileUrl"=>$result['result'][0]['invoiceFileUrl'],
                    "invoiceNum"=>$result['result'][0]["invoiceNum"],
                    "invoiceCode"=>$result['result'][0]['invoiceCode']
                ]);

            $res=Db::table("car_order_invoice")
                        ->alias("a")
                        ->join("car_order b","a.order_id=b.order_id")
                        ->where('a.order_id',$order_id)
                        ->field("a.*,b.parkingNo,b.out_trade_no")
                        ->find();
            return $this->redirect($result['result'][0]['invoiceFileUrl']);
            $res["errorCode"]="0";
            return $res;
        }else{
            $res["errorCode"]="1";
            $res["error"]= $result['describe'];
            return $res;
            return json(['error' => $result['describe']]);
        }
    }
    
    public function delivery(){
	    if(request()->isPost()){
	        $data=request()->post();
	        $billinfo = (new billService())->billIdinfo($data["id"]);
	        
            $communityinfo = (new billService())->communityName($billinfo['community_id']);
            $propertyinfo = (new billService())->propertyInfo($communityinfo['property_id']);
            $serviceinfo = (new billService())->serviceInfo($propertyinfo['service_id']);
            //判断access_token是否到期
            $second = strtotime(date('Y-m-d H:i:s',time()))-strtotime($serviceinfo['fp_expires_in']);
            if($second < 86400){
                //未过期
                $access_token = $serviceinfo['fp_access_token'];
            }else{
                //过期从新获取
                $access_token = $this->accessToken($serviceinfo['fp_app_key'],$serviceinfo['fp_app_secret']);
                //return $access_token;
            }
	        $phone=$data["phone"];
	        $mail=$data["mail"];
	        $url = "https://sdk.nuonuo.com/open/v1/services"; 
    	    $method = "nuonuo.ElectronInvoice.deliveryInvoice";
    	    
	        $appKey = $serviceinfo["fp_app_key"];
     	    $appSecret = $serviceinfo["fp_app_secret"];
    	    $token = $access_token;// please store the token and refresh it before expired
    	    $taxnum = $serviceinfo["fp_saler_tax_num"];
            
            $senid = uniqid(); //唯一标识，由企业自己生成32位随机码
            $body = '{"invoiceSerialNum":["your.voicecode"]}';//API私有请求参数
            $invoiceCode=$billinfo["invoiceCode"];
            $invoiceNum=$billinfo["invoiceNum"];
            $body="{
                  \"mail\": \"$mail\",
                  \"phone\": \"$phone\",
                  \"taxnum\": \"$taxnum\",
                  \"invoiceCode\": \"$invoiceCode\",
                  \"invoiceNum\": \"$invoiceNum\"
                }";
            $res = Api::sendPostSyncRequest($url, $senid, $appKey, $appSecret, $token, $taxnum, $method, $body);
            $result = json_decode($res, true);
		
            if($result['code'] == 'E0000'){
                $msg["mail"]=$mail;
                $msg["phone"]=$phone;
                $msg["taxnum"]=$taxnum;
                $msg["invoiceCode"]=$invoiceCode;
                $msg["invoiceNum"]=$invoiceNum;
                $msg["create_time"]=time();
                Db::table("invoice_msg_log")->insert($msg);
               return "信息推送成功";
            }else{
                return json(['error' => $result['describe']]);
            }
	    }else{
	        $id=request()->get("id");
	        
            $billinfo = (new billService())->billIdinfo($id);
            $this->assign("info",$billinfo);
            return $this->fetch();
	    }
	    
	}

	
	
	
	//导出车辆进出数据
    public function orderExcel(){
        
        //获取账单数据
        $export = request()->param('export');
        $export = str_replace("|","\"",$export);
        
        $where = json_decode($export,true);
		$parkingNo=$this->getParkingNo();

        $orderlist = Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->order('a.order_id desc')->select();
        //var_dump($orderlist);die;
		if(empty($orderlist)){
			return "没有数据";
		}
        
        $newExcel = new Spreadsheet();  //创建一个新的excel文档
        $objSheet = $newExcel->getActiveSheet();  //获取当前操作sheet的对象
        //设置宽度为true,不然太窄了
        $newExcel->getActiveSheet()->getColumnDimension('A')->setAutoSize(true);
        $newExcel->getActiveSheet()->getColumnDimension('B')->setAutoSize(true);
        
        //设置第一栏的标题
       
	    $objSheet->setTitle('停车账单');  //设置当前sheet的标题
        //设置第一栏的标题
        $objSheet->setCellValue('A1', '停车场')
	                ->setCellValue('B1', '车牌')
	                ->setCellValue('C1', '应收金额')
	                ->setCellValue('D1', '实收金额')
	                ->setCellValue('E1', '缴费方式')
	                ->setCellValue('F1', '缴费时间')
	                ->setCellValue('G1', '入场时间')
	                ->setCellValue('H1', '出场时间')
	                ->setCellValue('I1', '停车时长');            
        

        $i=2;  //定义一个i变量，目的是在循环输出数据是控制行数
        $count =Db::name('car_order')->alias("a")->where('a.parkingNo','in',$parkingNo)->where($where)->count();  //计算有多少条数据
        for ($i = 2; $i <= $count+1; $i++) {
            $objSheet->setCellValue('A' . $i, $orderlist[$i-2]["parkingName"]);
            $objSheet->setCellValue('B' . $i, $orderlist[$i-2]["carPlateNo"]);
            $objSheet->setCellValue('C' . $i, $orderlist[$i-2]["amountDue"]/100);
            $objSheet->setCellValue('D' . $i, $orderlist[$i-2]["amountRec"]/100);
            $paytype="支付宝扫码";
            if($orderlist[$i-2]["payType"]=="2"){
                $paytype="微信扫码";
            }
            if($orderlist[$i-2]["payType"]=="3"){
                $paytype="优惠券";
            }
            if($orderlist[$i-2]["payType"]=="cash"){
                $paytype="现金";
            }
            $objSheet->setCellValue('E' . $i,$paytype);
            $objSheet->setCellValue('F' . $i, date("Y-m-d H:i:s",strtotime($orderlist[$i-2]["paytime"])));
            $objSheet->setCellValue('G' . $i, date("Y-m-d H:i:s",strtotime($orderlist[$i-2]["parkingStartTime"])));
            $objSheet->setCellValue('H' . $i, date("Y-m-d H:i:s",strtotime($orderlist[$i-2]["parkingEndTime"])));
            $objSheet->setCellValue('I' . $i, ctime($orderlist[$i-2]["parkingTime"]));
            
            
        }
        $this->downloadExcel($newExcel, "停车账单", 'Xls');
    }
    function downloadExcel($newExcel, $filename, $format)
    {
        // $format只能为 Xlsx 或 Xls
        if ($format == 'Xlsx') {
            header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
        } elseif ($format == 'Xls') {
            header('Content-Type: application/vnd.ms-excel');
        }

        header("Content-Disposition: attachment;filename="
            . $filename . date('Y-m-d') . '.' . strtolower($format));
        header('Cache-Control: max-age=0');
        $objWriter = IOFactory::createWriter($newExcel, $format);

        $objWriter->save('php://output');

        //通过php保存在本地的时候需要用到
        //$objWriter->save($dir.'/demo.xlsx');

        //以下为需要用到IE时候设置
        // If you're serving to IE 9, then the following may be needed
        header('Cache-Control: max-age=1');
//         If you're serving to IE over SSL, then the following may be needed
        header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
        header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
        header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
        header('Pragma: public'); // HTTP/1.0
        exit;
    }	
	public function unpayList(){
		$adminId = session('id');
        $usertype = Db::name('admin')->where('id',$adminId)->value('usertype');
        $this->assign('usertype',$usertype);
        //根据当前账号查询区域
        $com = (new Common())->pidTokenId();
        $whe['community_id'] = array('in',implode(',',$com['community_id']));
        //根据账号查询停车场
        $parkinglist = (new orderService())->parkingList($whe);
        $this->assign('parkinglist',$parkinglist);
        //查询停车场ID
        if(!empty($parkinglist)){
            foreach($parkinglist as $park){
                $out_parking_id[] = $park['out_parking_id'];
            }
            //将数组转换成字符串
            $out_parking_id = implode(',',$out_parking_id);
        }else{
            $out_parking_id = null;
        }
        //搜索
        $data = request()->get();
		
        if (!empty($data)){
            if(!empty($data['out_parking_id'])){
                $where['out_parking_id'] = $data['out_parking_id'];//停车场名称
            }else{
                $where['out_parking_id'] = "";
            }
            if(!empty($data['order_no'])){
                $where['order_no'] = $data['order_no'];//订单号
            }else{
                $where['order_no'] = "";
            }
            if(!empty($data['car_number'])){
				if(is_array($data['car_number'])){
                    $where['car_number'] = array('like','%'.$data['car_number'][1].'%');//车牌号码
                }else{
                    $where['car_number'] = array('like','%'.$data['car_number'].'%');//车牌号码
                }
                //$where['car_number'] = $data['car_number'];//车牌号码
            }else{
                $where['car_number'] = "";
            }
            if(!empty($data['pay_type'])){
                $where['pay_type'] = $data['pay_type'];//付款方式
            }else{
                $where['pay_type'] = "";
            }
            if(!empty($data['status'])){
                $where['status'] = $data['status'];//状态
            }else{
                $where['status'] = "";
            }
			if(!empty($data['start_time'])){
                $where['in_time'] = array('>=',$data['start_time']);//入场时间
            }else{
                $where['in_time'] = "";
            }
            if(!empty($data['end_time'])){
                $where['in_time'] = array('<=',$data['end_time']);//入场时间
            }else{
                $where['end_time'] = "";
            }
            $this->assign('where',$where);
            $where = array_filter($where);
        }else{
            $where=array();
        }
		$where["pay_money"]=array('neq','');
		
		$where["order_status"]=array('eq','0');
		$export = $where;
        $export = json_encode($export);
        $export = str_replace("\"","|",$export);
        $this->assign('export',$export);
        $page = request()->has('page') ? request()->get('page') : 1;
        //多条件查询地库车位信息
        $orderlist =Db::name('car_order_del')->where('out_parking_id','in',$out_parking_id)->where($where)->order('out_time desc')->paginate(100, false, [
            'page'  =>  $page,
            'query' =>  $where
        ]);
        $number =Db::name('car_order_del')->where('out_parking_id','in',$out_parking_id)->where($where)->count();
        $this->assign('number',$number);
        $this->assign('list',$orderlist);
        $this->assign('orderlist',$orderlist);
        foreach ($data as $k => $v) {
            $this->assign($k, $v);
        }
        return $this->fetch('unpay_list');
	}
    public function nolicenseList(){
		$adminId = session('id');
        $usertype = Db::name('admin')->where('id',$adminId)->value('usertype');
        $this->assign('usertype',$usertype);
        //根据当前账号查询区域
        $com = (new Common())->pidTokenId();
        $whe['community_id'] = array('in',implode(',',$com['community_id']));
        //根据账号查询停车场
        $parkinglist = (new orderService())->parkingList($whe);
        $this->assign('parkinglist',$parkinglist);
        //查询停车场ID
        if(!empty($parkinglist)){
            foreach($parkinglist as $park){
                $out_parking_id[] = $park['out_parking_id'];
            }
            //将数组转换成字符串
            $out_parking_id = implode(',',$out_parking_id);
        }else{
            $out_parking_id = null;
        }
        //搜索
        $data = request()->get();
		
        if (!empty($data)){
            if(!empty($data['out_parking_id'])){
                $where['out_parking_id'] = $data['out_parking_id'];//停车场名称
            }else{
                $where['out_parking_id'] = "";
            }
            if(!empty($data['order_no'])){
                $where['order_no'] = $data['order_no'];//订单号
            }else{
                $where['order_no'] = "";
            }
            if(!empty($data['car_number'])){
				if(is_array($data['car_number'])){
                    $where['car_number'] = array('like','%'.$data['car_number'][1].'%');//车牌号码
                }else{
                    $where['car_number'] = array('like','%'.$data['car_number'].'%');//车牌号码
                }
                //$where['car_number'] = $data['car_number'];//车牌号码
            }else{
                $where['car_number'] = "";
            }
            if(!empty($data['pay_type'])){
                $where['pay_type'] = $data['pay_type'];//付款方式
            }else{
                $where['pay_type'] = "";
            }
            if(!empty($data['status'])){
                $where['status'] = $data['status'];//状态
            }else{
                $where['status'] = "";
            }
			if(!empty($data['start_time'])){
                $where['in_time'] = array('>=',$data['start_time']);//入场时间
            }else{
                $where['in_time'] = "";
            }
            if(!empty($data['end_time'])){
                $where['in_time'] = array('<=',$data['end_time']);//入场时间
            }else{
                $where['end_time'] = "";
            }
            $this->assign('where',$where);
            $where = array_filter($where);
        }else{
            $where=array();
        }
		$where["operator"]=array('neq','0');
		$export = $where;
        $export = json_encode($export);
        $export = str_replace("\"","|",$export);
        $this->assign('export',$export);
        $page = request()->has('page') ? request()->get('page') : 1;
        //多条件查询地库车位信息
        $orderlist = (new orderService())->orderWhereList($page,$where,$out_parking_id);
        $number = count((new orderService())->orderWhereListNumber($where));
        $this->assign('number',$number);
        $this->assign('list',$orderlist);
        $this->assign('orderlist',$orderlist);
        foreach ($data as $k => $v) {
            $this->assign($k, $v);
        }
        return $this->fetch('order_list_nolicense');
	}
	//账单删除及进出记录删除
    public function orderDel(){
		$com = (new Common())->pidTokenId();
        $id = request()->param('id');
	
		$orderinfo=Db::table("car_order")->where("order_id",$id)->find();
		$orderinfo["operate_del_name"]=session("name");
		Db::table("car_order_del")->insert($orderinfo);
		$bool= Db::name('car_order')->delete($id);
		
        if($bool){

			/*if($orderinfo["pay_type"]=="13")
			{
				Db::table("car_order_welfare")->where("order_id",$orderinfo["id"])->update(["status"=>"2"]);
			}*/
            $this->success('删除成功');
        }else{
            $this->error('删除失败');
        }
    }
    public function orderDelAll(){
        $idarr=request()->param('id');
        $idarr=explode(",",$idarr);
        Db::startTrans();
        try{
            foreach ($idarr as $value){
                $orderinfo=Db::table("car_order")->where("order_id",$value)->find();
                $orderinfo["operate_del_name"]=session("name");
                Db::table("car_order_del")->insert($orderinfo);
                $bool= Db::name('car_order')->delete($value);
            }
            // 提交事务
            Db::commit();
            return json(['info' => "删除成功"]);
        } catch (\Exception $e) {

            // 回滚事务
            Db::rollback();
            return json(['error' => $e->getMessage()]);
        }
    }
    public function getPayResult(){
        $id=request()->get("id");
    }
	
	
}